/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2010
 */

package com.tech15.core.model;


import java.util.HashSet;
import java.util.Set;

import javacommon.base.BaseEntity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;


/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "SYS_GROUP")
public class Group extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "PrivilegeGroup";
	public static final String ALIAS_PGID = "组序号";
	public static final String ALIAS_GROUPNAME = "组名";
	public static final String ALIAS_REMARK = "备注";
	public static final String APPID = "系统id";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * 组序号       db_column: PGID 
     */ 	
	
	private Long pgid;
    /**
     * 组名       db_column: GROUPNAME 
     */ 	
	@Length(max=20)
	private java.lang.String groupname;
    /**
     * 备注       db_column: REMARK 
     */ 	
	@Length(max=100)
	private java.lang.String remark;
	/**
     * 系统id       db_column: DID 
     */ 	
	private java.lang.Integer appid;
	
	private Integer isshfw;
	//columns END
	
	@Column(name = "ISSHFW", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
	public Integer getIsshfw() {
		return isshfw;
	}

	public void setIsshfw(Integer isshfw) {
		this.isshfw = isshfw;
	}


	public Group(){
	}

	public Group(
		Long pgid
	){
		this.pgid = pgid;
	}

	public void setPgid(Long value) {
		this.pgid = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "PGID", unique = true, nullable = false, insertable = true, updatable = true, length = 22)
	public Long getPgid() {
		return this.pgid;
	}
	
	@Column(name = "GROUPNAME", unique = false, nullable = true, insertable = true, updatable = true, length = 20)
	public java.lang.String getGroupname() {
		return this.groupname;
	}
	
	public void setGroupname(java.lang.String value) {
		this.groupname = value;
	}
	
	@Column(name = "REMARK", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getRemark() {
		return this.remark;
	}
	
	public void setRemark(java.lang.String value) {
		this.remark = value;
	}
	
	@Column(name = "APPID", unique = false, nullable = true, insertable = true, updatable = true, length = 3)
	public java.lang.Integer getAppid() {
		return this.appid;
	}
	
	public void setAppid(java.lang.Integer value) {
		this.appid = value;
	}
	
	
	private Set groupUsers = new HashSet(0);
	public void setGroupUsers(Set<GroupUser> groupUser){
		this.groupUsers = groupUser;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "group")
	public Set<GroupUser> getGroupUsers() {
		return groupUsers;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Pgid",getPgid())
			.append("Groupname",getGroupname())
			.append("Remark",getRemark())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getPgid())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Group == false) return false;
		if(this == obj) return true;
		Group other = (Group)obj;
		return new EqualsBuilder()
			.append(getPgid(),other.getPgid())
			.isEquals();
	}
	
	private String selectUserIds;
	private Long isauth;
	private boolean level;
	private String appname;

	@Transient
	public String getAppname() {
		return appname;
	}

	public void setAppname(String appname) {
		this.appname = appname;
	}

	@Transient
	public boolean isLevel() {
		return level;
	}

	public void setLevel(boolean level) {
		this.level = level;
	}

	@Transient
	public Long getIsauth() {
		return isauth;
	}

	public void setIsauth(Long isauth) {
		this.isauth = isauth;
	}

	@Transient
	public String getSelectUserIds() {
		return selectUserIds;
	}
	
	public void setSelectUserIds(String selectUserIds) {
		this.selectUserIds = selectUserIds;
	}
}

